//
//  CellForSelectCountryAndArea.m
//  ppkc2016
//
//  Created by 拼凑的断音 on 16/3/4.
//  Copyright © 2016年 拼凑的断音. All rights reserved.
//

#import "CellForSelectCountryAndArea.h"
#import "XXTool.h"

@interface CellForSelectCountryAndArea ()

@property (nonatomic) UILabel* countryLabel;

@property (nonatomic) UILabel* codeLabel;

@end

@implementation CellForSelectCountryAndArea

-(UILabel*)countryLabel
{
    if (_countryLabel==nil)
    {
        _countryLabel = [[UILabel alloc] init];
        _countryLabel.font = [XXTool systemFontOfSize:16];
        [self addSubview:_countryLabel];
    }
    return _codeLabel;
}

-(UILabel*)codeLabel
{
    if (_codeLabel==nil)
    {
        _codeLabel = [[UILabel alloc] init];
        _codeLabel.font = [XXTool systemFontOfSize:16];
        _codeLabel.textAlignment = NSTextAlignmentRight;
        _codeLabel.textColor = [UIColor grayColor];
        [self addSubview:_codeLabel];
    }
    return _codeLabel;
}

-(void)initParameter
{

}

-(void)initUI
{
    self.backgroundColor = [UIColor colorWithRed:235/255.0 green:235/255.0 blue:240/255.0 alpha:1.0];
    [self countryLabel];
    [self codeLabel];
}

-(void)refreshLayout:(CGRect)frame
{
    _countryLabel.frame = CGRectMake(10
                                     , 0
                                     , frame.size.width/2-10
                                     , frame.size.height);
    _codeLabel.frame = CGRectMake(_countryLabel.frame.origin.x+_countryLabel.frame.size.width
                                      , 0
                                      , _countryLabel.frame.size.width-15
                                      , _countryLabel.frame.size.height);
}

-(void)setInfo:(NSMutableDictionary *)info
{
    AreaCodeDBModel *use = [info objectForKey:cellForSelectCountryAndAreaKey];
    if ([XXTool didCurrentLanguageChinese])
    {
        _countryLabel.text = use.countryC;
    }
    else
    {
        _countryLabel.text = use.countryE;
    }
    _codeLabel.text = use.areaCode;
}

@end
